import { EventBus } from "quasar";
import { boot } from "quasar/wrappers";

// "async" is optional;
// more info on params: https://v2.quasar.dev/quasar-cli/boot-files
export default boot(async (context) => {
  // window.addEventListener("unhandledrejection", function (event) {
  //   // 阻止未处理的rejected抛异常
  //   event && event.preventDefault();
  // });

  const { app, store } = context;
  const bus = new EventBus();
  app.config.globalProperties.$bus = bus;
  app.provide("bus", bus);

  if (window.electron) {
    window.electron.on("totalUnreadCount", function (event, data, ...args) {
      store.commit("common/setServerMessageCount", data);
    });
  }
});
